<template>
  <div>
    <div class="spinner">
      <div class="bounce1"></div>
      <div class="bounce2"></div>
      <div class="bounce3"></div>
    </div>
  </div>
</template>
<script>
import api from 'util/xhr'
import conf from 'conf/index'
export default {
  created() {
    // 将得到的ticket兑换accessToken
    let { toUrl, ticket } = this.$route.query
    api
      .post('/api/m/loginByUC', {
        ticket: ticket
      })
      .then(
        data => {
          if (data.accessToken) {
            let areamTeamId = window.sessionStorage.getItem('globalAreaTeamId') || '564701030634225664'
            window.sessionStorage.setItem('accessToken', data.accessToken)
            let url = ''
            if (toUrl.indexOf('/jumpFeedback') > -1) {
              url = `${conf.feedback}#/list?accessToken=${
                data.accessToken
              }&areamTeamId=${areamTeamId}`
              window.location.replace(url)
            } else if (toUrl.indexOf('/jumpReport') > -1) {
              url = encodeURI(
                conf.report +
                  '#/report?' +
                  'areamTeamId=' +
                  areamTeamId +
                  '&accessToken=' +
                  data.accessToken
              )
              window.location.replace(url)
            } else {
              window.location.replace(`${decodeURIComponent(toUrl)}`)
            }
          }
        },
        () => {
          window.location.href = '/'
        }
      )
  }
}
</script>

<style lang="less" scoped>
.spinner {
  margin: 0 auto;
  padding-top: 300px;
  width: 300px;
  text-align: center;
}

.spinner > div {
  width: 60px;
  height: 60px;
  background-color: #000;
  border-radius: 100%;
  display: inline-block;
  -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
  animation: bouncedelay 1.4s infinite ease-in-out;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

.spinner .bounce1 {
  -webkit-animation-delay: -0.32s;
  animation-delay: -0.32s;
}

.spinner .bounce2 {
  -webkit-animation-delay: -0.16s;
  animation-delay: -0.16s;
}

@-webkit-keyframes bouncedelay {
  0%,
  80%,
  100% {
    -webkit-transform: scale(0);
  }
  40% {
    -webkit-transform: scale(1);
  }
}

@keyframes bouncedelay {
  0%,
  80%,
  100% {
    transform: scale(0);
    -webkit-transform: scale(0);
  }
  40% {
    transform: scale(1);
    -webkit-transform: scale(1);
  }
}
</style>

